package com.maijinjie.admin.content.service.impl;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.maijinjie.common.bean.Pagination;
import com.maijinjie.common.bean.StatusBean;
import com.maijinjie.admin.content.bean.OnlineEnrollmentBean;
import com.maijinjie.admin.content.dao.OnlineEnrollmentMapper;
import com.maijinjie.admin.content.field.OnlineEnrollmentFields;
import com.maijinjie.admin.content.service.OnlineEnrollmentService;
import com.maijinjie.common.service.impl.BaseServiceImpl;

/**
 * OnlineEnrollmentServiceImpl
 * @author 罗正杰
 **/
@Service("onlineEnrollmentService")
public class OnlineEnrollmentServiceImpl extends BaseServiceImpl implements OnlineEnrollmentService{
	@Resource
	OnlineEnrollmentMapper onlineEnrollmentMapper;
	
	@Override
	public OnlineEnrollmentBean getBeanById(Integer id) throws Exception{
		if(null==id || 0>=id){
			return null;
		} else {
			return (OnlineEnrollmentBean) getBeanById(onlineEnrollmentMapper, id);
		}
	}
	@Override
	public int count(Map<String, Object> params) throws Exception {
		return onlineEnrollmentMapper.count(params);
	}
	@Override
	public List<OnlineEnrollmentBean> list(Map<String, Object> params) throws Exception {
		return (List<OnlineEnrollmentBean>) onlineEnrollmentMapper.list(params);
	}
	@Override
	public StatusBean save(OnlineEnrollmentBean bean, String createBy, Integer createUserId) throws Exception {
		Date currDate = new Date();
		//TODO 处理业务
		
		if(0<onlineEnrollmentMapper.save(bean)){
			return success("操作成功！");
		}
		return error("操作失败！");
	}
	@Override
	public StatusBean update(OnlineEnrollmentBean bean, String createBy, Integer createUserId) throws Exception {
		if(null!=bean){
			Date currDate = new Date();
			HashMap<String, Object> params = new HashMap<String, Object>();
			//TODO 处理业务
			
			if(onlineEnrollmentMapper.update(params)){
				return success("操作成功！");
			}
		}
		return error("操作失败！");
	}
	@Override
	public StatusBean deleteById(Integer id) throws Exception {
		if(null!=id && 0<id){
			HashMap<String, Object> params = new HashMap<String, Object>();
			params.put(OnlineEnrollmentFields.id.toString(), id);
			if(onlineEnrollmentMapper.delete(params)){
				return success("操作成功！");
			}
		}
		return error("操作失败！");
	}
	@Override
	public Pagination<OnlineEnrollmentBean> list(Pagination<OnlineEnrollmentBean> pagination) throws Exception {
		return (Pagination<OnlineEnrollmentBean>) getPagination(onlineEnrollmentMapper, pagination);
	}
	@Override
	public StatusBean batchDelete(String ids) throws Exception {
		if(null!=ids && !"".equals(ids.trim())) {
			HashMap<String, Object> params = new HashMap<String, Object>();
			params.put(OnlineEnrollmentFields.id.toString(), ids);
			if(onlineEnrollmentMapper.batchDelete(params)){
				return success("操作成功！");
			}
		}
		return error("操作失败！");
	}
	@Override
	public List<OnlineEnrollmentBean> listAll() throws Exception {
		return (List<OnlineEnrollmentBean>) onlineEnrollmentMapper.list(null);
	}
}
